{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b875826a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name:55\n",
      "age:5555555\n",
      "job:55555555\n",
      "salary:55555555555\n",
      "-----------INFO 55----------\n",
      "name:55\n",
      "age:5555555\n",
      "job:55555555\n",
      "salary:55555555555\n",
      "-----------INFO 55----------\n",
      "name:55\n",
      "age:5555555\n",
      "job:55555555\n",
      "salary:55555555555\n",
      "-----------INFO 55----------\n",
      "name:55\n",
      "age:5555555\n",
      "job:55555555\n",
      "salary:55555555555\n",
      "\n",
      "https://www.nfu.edu.cn/gjdt/index1.htm\n",
      "https://www.nfu.edu.cn/gjdt/index2.htm\n",
      "https://www.nfu.edu.cn/gjdt/index3.htm\n",
      "https://www.nfu.edu.cn/gjdt/index4.htm\n",
      "https://www.nfu.edu.cn/gjdt/index5.htm\n",
      "https://www.nfu.edu.cn/gjdt/index6.htm\n",
      "https://www.nfu.edu.cn/gjdt/index7.htm\n",
      "https://www.nfu.edu.cn/gjdt/index8.htm\n",
      "https://www.nfu.edu.cn/gjdt/index9.htm\n",
      "https://www.nfu.edu.cn/gjdt/index10.htm\n",
      "https://www.nfu.edu.cn/gjdt/index11.htm\n",
      "https://www.nfu.edu.cn/gjdt/index12.htm\n",
      "https://www.nfu.edu.cn/gjdt/index13.htm\n",
      "https://www.nfu.edu.cn/gjdt/index14.htm\n",
      "https://www.nfu.edu.cn/gjdt/index15.htm\n",
      "https://www.nfu.edu.cn/gjdt/index16.htm\n",
      "https://www.nfu.edu.cn/gjdt/index17.htm\n",
      "https://www.nfu.edu.cn/gjdt/index18.htm\n",
      "https://www.nfu.edu.cn/gjdt/index19.htm\n",
      "https://www.nfu.edu.cn/gjdt/index20.htm\n",
      "https://www.nfu.edu.cn/gjdt/index21.htm\n",
      "https://www.nfu.edu.cn/gjdt/index22.htm\n",
      "https://www.nfu.edu.cn/gjdt/index23.htm\n",
      "https://www.nfu.edu.cn/gjdt/index24.htm\n",
      "https://www.nfu.edu.cn/gjdt/index25.htm\n",
      "https://www.nfu.edu.cn/gjdt/index26.htm\n",
      "内容:55555555555\n",
      "https://www.nfu.edu.cn/55555555555/index1.htm\n",
      "https://www.nfu.edu.cn/55555555555/index2.htm\n",
      "https://www.nfu.edu.cn/55555555555/index3.htm\n",
      "https://www.nfu.edu.cn/55555555555/index4.htm\n",
      "https://www.nfu.edu.cn/55555555555/index5.htm\n",
      "https://www.nfu.edu.cn/55555555555/index6.htm\n",
      "https://www.nfu.edu.cn/55555555555/index7.htm\n",
      "https://www.nfu.edu.cn/55555555555/index8.htm\n",
      "https://www.nfu.edu.cn/55555555555/index9.htm\n",
      "https://www.nfu.edu.cn/55555555555/index10.htm\n",
      "https://www.nfu.edu.cn/55555555555/index11.htm\n",
      "https://www.nfu.edu.cn/55555555555/index12.htm\n",
      "https://www.nfu.edu.cn/55555555555/index13.htm\n",
      "https://www.nfu.edu.cn/55555555555/index14.htm\n",
      "https://www.nfu.edu.cn/55555555555/index15.htm\n",
      "https://www.nfu.edu.cn/55555555555/index16.htm\n",
      "https://www.nfu.edu.cn/55555555555/index17.htm\n",
      "https://www.nfu.edu.cn/55555555555/index18.htm\n",
      "https://www.nfu.edu.cn/55555555555/index19.htm\n",
      "https://www.nfu.edu.cn/55555555555/index20.htm\n",
      "https://www.nfu.edu.cn/55555555555/index21.htm\n",
      "https://www.nfu.edu.cn/55555555555/index22.htm\n",
      "https://www.nfu.edu.cn/55555555555/index23.htm\n",
      "https://www.nfu.edu.cn/55555555555/index24.htm\n",
      "https://www.nfu.edu.cn/55555555555/index25.htm\n",
      "https://www.nfu.edu.cn/55555555555/index26.htm\n",
      "https://www.acfun.cn/v/list206/index.htm?sortField=rankScore&duration=all&date=default&page=1\n",
      "https://www.acfun.cn/v/list206/index.htm?sortField=rankScore&duration=all&date=default&page=2\n",
      "https://www.acfun.cn/v/list206/index.htm?sortField=rankScore&duration=all&date=default&page=3\n",
      "https://www.acfun.cn/v/list206/index.htm?sortField=rankScore&duration=all&date=default&page=4\n",
      "https://www.acfun.cn/v/list206/index.htm?sortField=rankScore&duration=all&date=default&page=5\n",
      "https://www.acfun.cn/v/list87/index.htm?sortField=rankScore&duration=all&date=default&page=1\n",
      "https://www.acfun.cn/v/list87/index.htm?sortField=rankScore&duration=all&date=default&page=2\n",
      "https://www.acfun.cn/v/list87/index.htm?sortField=rankScore&duration=all&date=default&page=3\n",
      "https://www.acfun.cn/v/list87/index.htm?sortField=rankScore&duration=all&date=default&page=4\n",
      "https://www.acfun.cn/v/list87/index.htm?sortField=rankScore&duration=all&date=default&page=5\n",
      "https://www.acfun.cn/v/list188/index.htm?sortField=rankScore&duration=all&date=default&page=1\n",
      "https://www.acfun.cn/v/list188/index.htm?sortField=rankScore&duration=all&date=default&page=2\n",
      "https://www.acfun.cn/v/list188/index.htm?sortField=rankScore&duration=all&date=default&page=3\n",
      "https://www.acfun.cn/v/list188/index.htm?sortField=rankScore&duration=all&date=default&page=4\n",
      "https://www.acfun.cn/v/list188/index.htm?sortField=rankScore&duration=all&date=default&page=5\n",
      "w\n",
      "y\n",
      ",\n",
      "['Jack', 463434, 23]\n",
      "[['zc', 123435, 19], ['Jack', 463434, 23]]\n",
      "[['zc', 123435, 19], ['Jack', 463434, 23], ['Alex', 583495, 25]]\n",
      "['Marry', 438294, 27]\n",
      "[['zc', 123435, 19], ['Jack', 463434, 23], ['Alex', 583495, 25], ['Marry', 438294, 27]]\n",
      "[0, 1, 2, 3, 4, 5]\n",
      "[0, 2, 4]\n"
     ]
    }
   ],
   "source": [
    "# week 05\n",
    "# 列表的入门\n",
    "# 用户输入与定制化打印（打印出自己规定的格式）\n",
    "\n",
    "# 一.input\n",
    "# 第一种\n",
    "name = input(\"name:\")\n",
    "age = input(\"age:\")\n",
    "job = input(\"job:\")\n",
    "salary = input(\"salary:\")\n",
    "\n",
    "# 以name为基准（INFO ''' + name + '''）将内容动态得打印出来,字符串的拼接 用 \"+\" 符号来拼接\n",
    "info = '''-----------INFO ''' + name + '''----------\n",
    "name:'''+name+'''\n",
    "age:'''+age+'''\n",
    "job:'''+job+'''\n",
    "salary:'''+salary\n",
    "print(info)\n",
    "\n",
    "# 优化使用\n",
    "# 第二种，以%s为基准\n",
    "info_ss = '''-----------INFO %s----------\n",
    "name:%s\n",
    "age:%s\n",
    "job:%s\n",
    "salary:%s''' % (name, name, age, job, salary)\n",
    "print(info_ss)\n",
    "# 对比二者区别\n",
    "# 优势 1.减少+的使用，简洁美观。 2.将所需内容包含在一个大的字符串里面\n",
    "# 劣势 1.顺序一乱打印结果不准确。 2.不适用于过大内容的数据库。\n",
    "\n",
    "# 第三种\n",
    "# 在第二种%s的基础上优化，采用format格式化字符串，可以一一对应内容，清晰出错率低。\n",
    "info_sss = '''-----------INFO {姓名}----------\n",
    "name:{姓名}\n",
    "age:{年龄}\n",
    "job:{工作}\n",
    "salary:{薪水}\n",
    "'''.format(年龄=age, 姓名=name, 工作=job, 薪水=salary)\n",
    "print(info_sss)\n",
    "\n",
    "\n",
    "# 二.url 网页\n",
    "# 1.以学校网站为例\n",
    "url = \"https://www.nfu.edu.cn/\"  # 官网首页\n",
    "# 目标获取官网所有url网页\n",
    "# 第一种链接方式\n",
    "高教动态 = \"gjdt\"\n",
    "url_页面 = \".htm\"\n",
    "url_页面细节不变 = \"/index\"\n",
    "for i in range(1, 27):\n",
    "    完整的高教动态所有页面url = url + 高教动态 + url_页面细节不变 + str(i) + url_页面\n",
    "    print(完整的高教动态所有页面url)\n",
    "#  url可缩写 可具体写出来网址（见第二种方式\n",
    "\n",
    "# 第二种链接方式\n",
    "vv = input(\"内容:\")\n",
    "for i in range(1, 27):\n",
    "   完整的高教动态所有页面url = \"https://www.nfu.edu.cn/{内容}/index{页码}.htm\".format(页码=str(i), 内容=vv)\n",
    "   print(完整的高教动态所有页面url)\n",
    "\n",
    "# 2.以 acfun为例\n",
    "# acfun娱乐区为例 三个例子 搞笑区=list206 鬼畜区=list87 明星区=list188\n",
    "fq = ['list206', 'list87', 'list188']\n",
    "url = \"https://www.acfun.cn/\"\n",
    "ym = [1, 2, 3, 4, 5]\n",
    "# 页面后缀 = /index.htm?sortField=rankScore&duration=all&date=default&page=\n",
    "for g in fq:\n",
    "    for v in ym:\n",
    "        娱乐区所有页面url = 'https://www.acfun.cn/v/{分区}/index.htm?sortField=rankScore&duration=all&date=default&page={页面}'.format(分区=str(g), 页面=str(v))\n",
    "        print(娱乐区所有页面url)\n",
    "\n",
    "\n",
    "# 三.list\n",
    "# 列表入门学习\n",
    "# 1.用模拟用户登录\n",
    "user_data = \"wy,wyt,wyy,wyy\"\n",
    "print(user_data[0])  # 为零号位也就是w，首位为0.\n",
    "print(user_data[1])  # 以此类推\n",
    "print(user_data[2])\n",
    "# 2.用list来模拟用户数据\n",
    "user_data_list = [[\"zc\", 123435, 19], [\"Jack\", 463434, 23], [\"Alex\", 583495, 25], [\"Marry\", 438294, 27]]\n",
    "password_list = [123435, 463434, 583495, 438294]\n",
    "age = [19, 20, 22, 25]\n",
    "# list是从左往右取值的。\n",
    "print(user_data_list[1])\n",
    "# 切片 slice ，右边的值取不到 例如[0:3] 索引为3的值取不到\n",
    "print(user_data_list[0:2])\n",
    "# 0可以忽略不写，当0（第一位也要取到的时候）\n",
    "print(user_data_list[:3])\n",
    "# 负值取值 从右往左数\n",
    "print(user_data_list[-1])\n",
    "# list应该是[-3:],不能写[-3:0]\n",
    "# 取全部值\n",
    "print(user_data_list[:])\n",
    "'''\n",
    "取值为空即出现了错误。\n",
    "'''\n",
    "# 3.三个重要的值\n",
    "# [start:stop:step] 分别对应开始值，结束值，步长（间隔）。\n",
    "# 开始值默认为0，结束值默认为方框内规定的数字，步长默认为1（下面实例中改为2）\n",
    "num = list(range(6))  # 从0到6，但6取不到，默认从0开始，0取得到。\n",
    "print(num)            # 输出上面的列表\n",
    "print(num[0:6:2])     # 0为开始值，6为结束值，2为步长。\n",
    "\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9e2bb49e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
